package com.cyandpos.pad.posdata;


import com.cyandpos.pad.common.commondata.ErpCommonData;
import com.cyandpos.pad.utils.MoneyUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2020/2/10.
 */

public class TicketInfo implements Serializable {
    private String cent;//交易本次积分
    private String sktno;//款台号
    private String jlbh;//小票号
    private String orderNo;//订单号
    private String serverBillId;//CRM交易号
    private String storeCode;//分店号
    private String totalCount;//订单总数量
    private String totalAmount;//总金额(元)
    private String totalDiscount;//总折扣(元)
    private String decMoney;//满减金额(元)
    private String decPreferentialMoney;//满抵金额
    private String changeAmount ="0";//找零金额(元)
    private String overflowAmount;//溢余金额(元)
    private boolean needBuyCent;//是否需要钱买分
    private boolean needVipToOfferCoupon;//是否需要返券后刷卡
    private String offerCouponVipCode;//返券会员号---返券后刷卡会员code
    private int offerCouponVipId;//返券后刷卡会员id
    private int orderFunction;// =1 订金单标识
    private List<Payment> payList;//付款信息列表
    private Member memberInfo;//会员信息
    private Person  casherInfo;//收款员信息
    private List<OfferCoupon> offerCouponList;//返券列表
    private List<Lotto> lottoList;//抽奖列表
    private List<SubTicketItem> subTickets;//子小票列表---
    private String oldOrderNo ="";//原订单号
    private String orderTime;//订单完成时间
    private List<CardCouponItem> cardCouponList;//卡券列表
    private List<CashCardItem> cashCardList;//储值卡列表
    private List<CodeCoupon>codedCouponList;//编码券列表
    private List<O2OPayDetail> o2oZfbList;//支付宝列表
    private List<O2OPayDetail> o2oWxList;//微信列表
    private List<O2OPayDetail> jhList;//聚合列表
    private List<YhkCardItem> bankCardList;//银行卡
    private List<DepositUseData> depositUsedList;//使用订金列表
    private DjdData depositOrderInfo;//生成订金详情
    private String tableNo;//桌号
    private String tablePerson;//桌号人数
    private int tableState;//状态
    private boolean isFSTH;//是否负数退货  true 负数退货
    private boolean isDJD;//是否订金单     true 订金单
    public String getTablePerson() {
        return tablePerson;
    }

    public void setTablePerson(String tablePerson) {
        this.tablePerson = tablePerson;
    }

    public int getTableState() {
        return tableState;
    }

    public void setTableState(int tableState) {
        this.tableState = tableState;
    }

    public String getTableNo() {
        return tableNo;
    }

    public void setTableNo(String tableNo) {
        this.tableNo = tableNo;
    }

    public TicketInfo() {
        payList = new ArrayList<>();
        offerCouponList = new ArrayList<>();
        lottoList = new ArrayList<>();
        subTickets = new ArrayList<>();
        cardCouponList = new ArrayList<>();
        cashCardList = new ArrayList<>();
        o2oZfbList = new ArrayList<>();
        o2oWxList = new ArrayList<>();
        jhList= new ArrayList<>();
        codedCouponList = new ArrayList<>();
        bankCardList = new ArrayList<>();
        depositUsedList = new ArrayList<>();
    }

    public List<O2OPayDetail> getJhList() {
        return jhList;
    }

    public void setJhList(List<O2OPayDetail> jhList) {
        this.jhList = jhList;
    }

    public List<YhkCardItem> getBankCardList() {
        return bankCardList;
    }

    public void setBankCardList(List<YhkCardItem> bankCardList) {
        this.bankCardList = bankCardList;
    }

    public List<DepositUseData> getDepositUsedList() {
        return depositUsedList;
    }

    public void setDepositUsedList(List<DepositUseData> depositUsedList) {
        this.depositUsedList = depositUsedList;
    }

    public int getOrderFunction() {
        return orderFunction;
    }

    public void setOrderFunction(int orderFunction) {
        this.orderFunction = orderFunction;
    }



    public String getSktno() {
        return sktno;
    }

    public void setSktno(String sktno) {
        this.sktno = sktno;
    }

    public String getJlbh() {
        return jlbh;
    }

    public void setJlbh(String jlbh) {
        this.jlbh = jlbh;
    }

    public String getOrderNo() {
        return orderNo;
    }

    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }

    public String getServerBillId() {
        return serverBillId;
    }

    public void setServerBillId(String serverBillId) {
        this.serverBillId = serverBillId;
    }

    public String getStoreCode() {
        return storeCode;
    }

    public void setStoreCode(String storeCode) {
        this.storeCode = storeCode;
    }

    public String getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(String totalCount) {
        this.totalCount = totalCount;
    }

    public String getTotalAmount() {
        return totalAmount;
    }

    public void setTotalAmount(String totalAmount) {
        this.totalAmount = totalAmount;
    }

    public String getTotalDiscount() {
        return totalDiscount;
    }

    public void setTotalDiscount(String totalDiscount) {
        this.totalDiscount = totalDiscount;
    }

    public String getDecMoney() {
        return decMoney;
    }

    public void setDecMoney(String decMoney) {
        this.decMoney = decMoney;
    }

    public String getChangeAmount() {
        return changeAmount;
    }

    public void setChangeAmount(String changeAmount) {
        this.changeAmount = changeAmount;
    }

    public String getOverflowAmount() {
        return overflowAmount;
    }

    public void setOverflowAmount(String overflowAmount) {
        this.overflowAmount = overflowAmount;
    }

    public boolean isNeedBuyCent() {
        return needBuyCent;
    }

    public void setNeedBuyCent(boolean needBuyCent) {
        this.needBuyCent = needBuyCent;
    }

    public boolean isNeedVipToOfferCoupon() {
        return needVipToOfferCoupon;
    }

    public void setNeedVipToOfferCoupon(boolean needVipToOfferCoupon) {
        this.needVipToOfferCoupon = needVipToOfferCoupon;
    }

    public String getOfferCouponVipCode() {
        return offerCouponVipCode;
    }

    public void setOfferCouponVipCode(String offerCouponVipCode) {
        this.offerCouponVipCode = offerCouponVipCode;
    }

    public List<Payment> getPayList() {
        return payList;
    }

    public void setPayList(List<Payment> payList) {
        this.payList = payList;
    }

    public Member getMemberInfo() {
        return memberInfo;
    }

    public void setMemberInfo(Member memberInfo) {
        this.memberInfo = memberInfo;
    }

    public Person getCasherInfo() {
        return casherInfo;
    }

    public void setCasherInfo(Person casherInfo) {
        this.casherInfo = casherInfo;
    }

    public List<OfferCoupon> getOfferCouponList() {
        return offerCouponList;
    }

    public void setOfferCouponList(List<OfferCoupon> offerCouponList) {
        this.offerCouponList = offerCouponList;
    }

    public List<Lotto> getLottoList() {
        return lottoList;
    }

    public void setLottoList(List<Lotto> lottoList) {
        this.lottoList = lottoList;
    }

    public List<SubTicketItem> getSubTickets() {
        return subTickets;
    }

    public void setSubTickets(List<SubTicketItem> subTickets) {
        this.subTickets = subTickets;
    }

    public String getOldOrderNo() {
        return oldOrderNo;
    }

    public void setOldOrderNo(String oldOrderNo) {
        this.oldOrderNo = oldOrderNo;
    }

    public String getOrderTime() {
        return orderTime;
    }

    public void setOrderTime(String orderTime) {
        this.orderTime = orderTime;
    }

    public String getCent() {
        return cent;
    }

    public void setCent(String cent) {
        this.cent = cent;
    }

    public List<CardCouponItem> getCardCouponList() {
        return cardCouponList;
    }

    public void setCardCouponList(List<CardCouponItem> cardCouponList) {
        this.cardCouponList = cardCouponList;
    }

    public List<CashCardItem> getCashCardList() {
        return cashCardList;
    }

    public void setCashCardList(List<CashCardItem> cashCardList) {
        this.cashCardList = cashCardList;
    }

    public List<O2OPayDetail> getO2oZfbList() {
        return o2oZfbList;
    }

    public void setO2oZfbList(List<O2OPayDetail> o2oZfbList) {
        this.o2oZfbList = o2oZfbList;
    }

    public List<O2OPayDetail> getO2oWxList() {
        return o2oWxList;
    }

    public void setO2oWxList(List<O2OPayDetail> o2oWxList) {
        this.o2oWxList = o2oWxList;
    }

    public List<CodeCoupon> getCodedCouponList() {
        return codedCouponList;
    }

    public void setCodedCouponList(List<CodeCoupon> codedCouponList) {
        this.codedCouponList = codedCouponList;
    }

    public int getOfferCouponVipId() {
        return offerCouponVipId;
    }

    public void setOfferCouponVipId(int offerCouponVipId) {
        this.offerCouponVipId = offerCouponVipId;
    }

    public String getDecPreferentialMoney() {
        return decPreferentialMoney;
    }

    public void setDecPreferentialMoney(String decPreferentialMoney) {
        this.decPreferentialMoney = decPreferentialMoney;
    }

    public boolean isFSTH() {
        return isFSTH;
    }

    public void setFSTH(boolean FSTH) {
        isFSTH = FSTH;
    }

    public boolean isDJD() {
        return isDJD;
    }

    public void setDJD(boolean DJD) {
        isDJD = DJD;
    }

    public DjdData getDepositOrderInfo() {
        return depositOrderInfo;
    }

    public void setDepositOrderInfo(DjdData depositOrderInfo) {
        this.depositOrderInfo = depositOrderInfo;
    }

    /**
     * 小票中已经支付的金额 单位（分）
     *
     * @return
     */
    public int getHasPayed() {
        int hasPayed = 0;
        for (Payment e : payList) {
            hasPayed += MoneyUtils.getMoneyInt(e.getPayAmount());
        }
        return hasPayed;
    }
    /**
     * 小票中已经支付的金额去除储值卡单位（分）
     *
     * @return
     */
    public int getHasPayedDeleteCard() {
        int hasPayed = 0;
        for (Payment e : payList) {
            if(e.getPayType()!=Payment.SKFS_CZK) {
                hasPayed += MoneyUtils.getMoneyInt(e.getPayAmount());
            }
        }
        return hasPayed;
    }
    public int getTicketGoodCount(){
        int goodCount = 0;
        for (SubTicketItem sub : subTickets) {
            goodCount += sub.getGoodsList().size();
        }
        return goodCount;
    }
    
    public void setTicket(Order order){
        setJlbh(order.getJlbh());
        setSktno(order.getSktno());
        setTotalAmount(order.getTotalAmount());
        setOrderNo(order.getOrderNo());
        setOrderTime(order.getOrderTime());
        setCasherInfo(order.getCasherInfo());
        setCent(order.getCent());
        setChangeAmount(order.getChangeAmount());
        setTotalDiscount(order.getTotalDiscount());
        setLottoList(order.getLottoList());
        setMemberInfo(order.getMemberInfo());
        setOfferCouponList(order.getOfferCouponList());
        setPayList(order.getPayList());
        setServerBillId(order.getServerBillId());
        setSubTickets(order.getSubTickets());
        setTotalCount(order.getTotalCount());
        setDecPreferentialMoney(order.getDecPreferentialMoney());
    }

    /**
     * 获取订单总金额 单位（分）
     * @return
     */
    public int getTotalMoney(){
        int totalMoney = MoneyUtils.getMoneyInt(totalAmount);
        return totalMoney;
    }

    @Override
    public String toString() {
        return "TicketInfo{" +
                "cent='" + cent + '\'' +
                ", sktno='" + sktno + '\'' +
                ", jlbh='" + jlbh + '\'' +
                ", orderNo='" + orderNo + '\'' +
                ", serverBillId='" + serverBillId + '\'' +
                ", storeCode='" + storeCode + '\'' +
                ", totalCount='" + totalCount + '\'' +
                ", totalAmount='" + totalAmount + '\'' +
                ", totalDiscount='" + totalDiscount + '\'' +
                ", decMoney='" + decMoney + '\'' +
                ", decPreferentialMoney='" + decPreferentialMoney + '\'' +
                ", changeAmount='" + changeAmount + '\'' +
                ", overflowAmount='" + overflowAmount + '\'' +
                ", needBuyCent=" + needBuyCent +
                ", needVipToOfferCoupon=" + needVipToOfferCoupon +
                ", offerCouponVipCode='" + offerCouponVipCode + '\'' +
                ", offerCouponVipId=" + offerCouponVipId +
                ", orderFunction=" + orderFunction +
                ", payList=" + payList +
                ", memberInfo=" + memberInfo +
                ", casherInfo=" + casherInfo +
                ", offerCouponList=" + offerCouponList +
                ", lottoList=" + lottoList +
                ", subTickets=" + subTickets +
                ", oldOrderNo='" + oldOrderNo + '\'' +
                ", orderTime='" + orderTime + '\'' +
                ", cardCouponList=" + cardCouponList +
                ", cashCardList=" + cashCardList +
                ", codedCouponList=" + codedCouponList +
                ", o2oZfbList=" + o2oZfbList +
                ", o2oWxList=" + o2oWxList +
                ", bankCardList=" + bankCardList +
                ", depositUsedList=" + depositUsedList +
                ", tableNo='" + tableNo + '\'' +
                ", tablePerson='" + tablePerson + '\'' +
                ", tableState=" + tableState +
                ", isFSTH=" + isFSTH +
                ", isDJD=" + isDJD +
                '}';
    }
}
